package com.mingyuan.library.domain.common.exception;


import com.mingyuan.library.domain.common.enums.ErrorEnumBase;
import lombok.Getter;

/**
 * 业务异常基类
 * @author yangzk
 * @version 1.0.0
 * @date 2022.11.06 11:50
 */
@Getter
public class BusinessException extends RuntimeException {

    private static final long serialVersionUID = 831169159531184899L;
    /**
     * 错误码
     */
    private final String errCode;

    public BusinessException(ErrorEnumBase error) {
        this(error.getErrCode(), error.getErrMessage());
    }

    public BusinessException(ErrorEnumBase error, Throwable cause) {
        this(error.getErrCode(), error.getErrMessage(), cause);
    }

    public BusinessException(String errCode, String message) {
        super(message);
        this.errCode = errCode;
    }

    public BusinessException(String errCode, String message, Throwable cause) {
        super(message, cause);
        this.errCode = errCode;
    }

}